#pragma once

#include <libge/libge.h>
#include <vector>
#include "Block.h"
#include "Sign.h"

class Client;

class Chunk {
public:
	Chunk(Client* cli);
	Chunk(Client* cli, int x, int y);
	~Chunk();
	Block* GetBlock(int x, int y, int z);
	Block* FindBlock(int x, int y, int z);
	void UpdateSign(int x, int y, int z, const char* l1, const char* l2, const char* l3, const char* l4);
	ge_Renderer* getRenderer();
	int getLod();
	bool isVisible();
	void setVisible(bool vi);
	bool isRendered();
	void setRendered(bool r);
	int getId();
	void setId(int i);
	int getX();
	int getY();
	int getNewX();
	int getNewY();
	void setX(int x);
	void setY(int y);
	void setNewX(int x);
	void setNewY(int x);
	bool Load(int x, int y);
	bool LoadSMP(u8* data, int datalen, u16 bitmask, u16 add_bitmask, bool skylight);
	void CalculateLighting();
	void LightingRecursion(int x, int y, int z, int n);
	void MakeSides();
	void MakeFarSides(int lod);
	bool isReserved();
	void setReserved(bool r);

private:
	void _init();
	bool visible;
	bool rendered;
	int id;
	int X, Y;
	int newX, newY;
	Client* client;
	Block* blocks; // TODO : split in 16 instead
	std::vector<Sign*> signs;
	ge_Renderer* render;
	bool reserved;
	int lod;
};

